


clear 
set scheme lean2, permanent
global pm = char(177)
set more off

gl date = c(current_date)
if c(os) == "MacOSX" gl user "/Users/`c(username)'"
else if c(os) == "Windows" gl user "C:\Users\\`c(username)'"
else if c(os) == "Unix" gl user "/usr/`c(username)'"
di "$user

set graphics on  
 
global path_data_processed "\data\processed"
global path_output "\data\output"

clear all
set more off

cd "$path_data_processed"
use "experimentRNall.dta", clear

cd "$path_output"
 
keep if posterior!=.

tempfile main
save `main', replace

clear all
eststo clear
estimates drop _all

loc columns = 6

set obs 10
gen x = 1
gen y = 1

forval i = 1/`columns' {
	eststo col`i': reg x y
} 

loc count = 1

loc statnames ""
loc varlabels ""

/* Custom fill cells */

use `main', clear

replace D_log_spending_f_t2=D_log_spending_f_t2*100

la var income "Household net income"
la var earnings "Individual gross earnings"
la var jobinsecurity "Personal unemployment: Probability"
la var D_log_spending_f_t2 "Non-durable spending growth (percent)"
la var stocktrade_f "Change in stockholdings (scale)"
la var unemp_county_prob "Higher unemployment (county): Probability"

foreach yvar of varlist female age atleast_bachelor income assets famsize single married separated divorced widowed ///
midwest west south northeast earnings hours construction manuf_nondurable manuf_durable transportation retail finance services health_educ ind_other ///
public_employer private_employer other_employer tenure democrat republican finlit_int finlit_infl finlit_div ///
emp_hiring emp_firing emp_profits ever_unemployed prior ///
unemp_cat unemp_prob unemp_county_prob fin_prosp earn_mean earn_sd jobinsecurity jobloss jobfind ///
infl_mean infl_sd profits spending D_log_spending_f_t2 durablepurchase_f stocks_incr_f stocks_decr_f {
 

	qui sum `yvar', d

	cap: estadd loc thisstat`count' = string(`r(mean)', "%9.2f"): col1
	cap: estadd loc thisstat`count' = string(`r(sd)', "%9.2f"): col2
	cap: estadd loc thisstat`count' = string(`r(p50)', "%9.2f"): col3
	cap: estadd loc thisstat`count' = string(`r(min)', "%9.2f"): col4
	cap: estadd loc thisstat`count' = string(`r(max)', "%9.2f"): col5
	cap: estadd loc thisstat`count' = `r(N)': col6

	/* Row Labels */
	
	loc thisvarlabel: variable label `yvar'
	local varlabels "`varlabels' "`thisvarlabel'" "
	loc statnames "`statnames' thisstat`count'"
	loc count = `count' + 1

}

/* Footnotes */

loc prehead "\begin{tabular}{l*{`columns'}{c}} \toprule"

loc postfoot "\bottomrule \end{tabular}"

loc footnote "This table presents basic summary statistics for each row variable."

esttab col* using "sumstats", booktabs cells(none) nonum nogap mtitle("Mean" "SD" "Median" "Min." "Max." "Obs.") stats(`statnames', labels(`varlabels')) note("`footnote'") prehead("`prehead'") postfoot("`postfoot'") compress wrap replace

eststo clear

